<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="zh">
<head>
    <meta charset="UTF-8">
    <title>学生列表</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            margin: 0;
            padding: 20px;
        }

        h1 {
            color: #333;
            text-align: center;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 20px;
            background-color: #fff;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        }

        th, td {
            padding: 10px;
            text-align: left;
            border-bottom: 1px solid #ddd;
        }

        th {
            background-color: #f8f8f8;
        }

        tr:hover {
            background-color: #f1f1f1;
        }

        a {
            color: #007bff;
            text-decoration: none;
        }

        a:hover {
            text-decoration: underline;
        }

        .message {
            color: green;
            margin-bottom: 20px;
        }

        .add-student {
            display: inline-block;
            padding: 10px 20px;
            background-color: #28a745;
            color: white;
            text-decoration: none;
            border-radius: 5px;
            margin-bottom: 20px;
        }

        .add-student:hover {
            background-color: #218838;
        }
    </style>
</head>
<body>
<h1>学生列表</h1>

<!-- 显示提示消息 -->
<p th:text="${message}" class="message"></p>
<!-- massage显示五秒 -->
<script>
    setTimeout(function () {
        document.querySelector('.message').style.display = 'none';
    }, 5000);
</script>

<table>
    <thead>
    <tr>
        <th>ID</th>
        <th>姓名</th>
        <th>性别</th>
        <th>年龄</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <tr th:each="student : ${studentList}">
        <td th:text="${student.id}"></td>
        <td th:text="${student.studentname}"></td>
        <td th:text="${student.gender}"></td>
        <td th:text="${student.age}"></td>
        <td>
            <a th:href="@{/student/{id}(id=${student.id})}">查看</a> |
            <a th:href="@{/student/edit/{id}(id=${student.id})}">编辑</a> |
            <a th:href="@{/student/delete/{id}(id=${student.id})}">删除</a>
        </td>
    </tr>
    </tbody>
</table>

<a href="/student/add" class="add-student">添加新学生</a>
</body>
</html>
